/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testdependencyinjection;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 * @author User
 */
public class TestDependencyInjection {
    public static void main(String[] args) throws InterruptedException {
	ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
				"testdependencyinjection/springbasic.xml");
	Bar bar = applicationContext.getBean("bar", Bar.class);
	bar.processFooName();
	System.out.println(bar.toString());
		/*
		 * if a single definition of a class type exists, then u can get the
		 * instance by this way also. No need to specify Id
		 */
	Foo foo = applicationContext.getBean(Foo.class);
	System.out.println(foo.getName());
        
        // Without dependecy injection
        Foo nombre = new Foo();
        nombre.setName("Marcelino");
        System.out.println(nombre.getName());
        
        // New class and dependency
        Tercero newbean = applicationContext.getBean(Tercero.class);
        newbean.metodo3();
	}
}
